package cn.doitedu.javase.calculate_engine.server;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class DefaultHandler implements RequestHandler{
    @Override
    public byte[] handlerRequest(UrlAndParams urlAndParams) throws IOException {

        String body = FileUtils.readFileToString(new File("html/404.html"), "UTF-8");

        String response =
                "HTTP/1.1 200 OK\n" +  // 响应行
                        "Content-Type:text/html;charset=UTF-8\n" +  // 响应头
                        "\n" +  // 空行
                        body;  // 响应体

        return response.getBytes(StandardCharsets.UTF_8);
    }
}
